package com.nondo.rdp.finance.service.impl.setting.home;

import com.nondo.rdp.finance.domain.setting.home.SettingModule;
import com.nondo.rdp.finance.repository.setting.home.SettingModuleRepository;
import com.nondo.rdp.finance.service.setting.home.SettingModuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service
public class SettingModuleServiceImpl implements SettingModuleService {
    @Autowired
    SettingModuleRepository settingModuleRepository;

    @Override
    public SettingModule findOne(Long id) {
        return this.settingModuleRepository.findOne(id);
    }

    @Override
    public SettingModule save(SettingModule settingModule) {
        return this.settingModuleRepository.save(settingModule);
    }

    @Override
    public void update(SettingModule settingModule) {
        this.settingModuleRepository.save(settingModule);
    }

    @Override
    public void delete(Long id) {
        this.settingModuleRepository.deleteById(id);
    }

    @Override
    public List<SettingModule> findAllByStatus(Sort sort) {
        return this.settingModuleRepository.findAllByStatusAndDelFlag(0, sort, "0");
    }

    @Override
    public List<SettingModule> findAll(Sort sort) {
        return this.settingModuleRepository.findAll(sort);
    }
}